package Thread;
class Singleton2{
    //懒汉模式,我们就不需要一开始就创建实例,而是把创建实例的选择权交给程序员
    private static volatile Singleton2 instance = null;
    private static Object locker = new Object();
    public static Singleton2 getInstance() {
        if (instance == null) {
            synchronized (locker) {
                if (instance == null) {
                    instance = new Singleton2();
                }
            }
        }
                return instance;
    }
    private Singleton2(){}
}
public class ThreadDemo1 {
}
